//
//  SQConfirmViewController.m
//  energy
//
//  Created by 周曼迪 on 2021/7/7.
//

#import "SQConfirmViewController.h"
#import "SQConfirmModel.h"
#import "SQConfirmLookViewController.h"
#import "SQConfirmConfirmViewController.h"


@interface SQConfirmViewController ()<BaseTableVCInterface>


@end

@implementation SQConfirmViewController

- (void)viewDidLoad {
    self.tableViewInterface = self;
    [super viewDidLoad];
    self.navigationItem.title = @"隐患确认";
    [self getConfirmData];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getConfirmData) name:@"confirm" object:nil];
    
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [self getConfirmData];
    }];
    
    LC_WEAK_SELF
    self.cellTitleIndex = ^(NSString * str, int key) {
        SQConfirmModelData * dataModel = weakSelf.dataSouece[key];
        if ([str isEqualToString:@"confirm"]) {
            SQConfirmConfirmViewController * confirmConfirmVC = SQConfirmConfirmViewController.new;
            confirmConfirmVC.hd_id = dataModel.hd_id;
            [weakSelf pushVC:confirmConfirmVC];
            
        }else if ([str isEqualToString:@"look"]){
            SQConfirmLookViewController * confirmLookVC = SQConfirmLookViewController.new;
            confirmLookVC.hd_id = dataModel.hd_id;
            [weakSelf pushVC:confirmLookVC];
            
        }else if ([str isEqualToString:@"del"]){
            
            
        }
    };
    
}

-(void)getConfirmData{
    NSInteger  api = 0;
        if ([MLevel isEqualToString:@"1"] ) {
            api = 0;
        }else if ( [MLevel isEqualToString:@"2"] ){
            api = 1;
        }else  if ( [MLevel isEqualToString:@"3"] ) {
            api = 2;
        }
    
    
    [SQConfirmModel getDataWithAPIIndex:api params:@{@"m_id":UID,@"m_one":MOne} WithCallBack:^(SQConfirmModel * data) {
        [self detailModelwithArr:data.data withCallBack:nil];
        [self reloadTableView];
        
    }];
}



-(NSInteger)rowsCount:(NSInteger)section{
    return self.dataSouece.count;
}


- (NSArray<NSArray<NSString *> *> *)classArr{
    return @[@[@"SQConfirmTableViewCell"]];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
